Merge with master
This commit is contained in:
+7
-14
@@ -16,22 +16,15 @@
|
||||
#ifndef JERRY_GLOBALS_H
|
||||
#define JERRY_GLOBALS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
typedef unsigned long mword_t;
|
||||
typedef mword_t uintptr_t;
|
||||
typedef mword_t size_t;
|
||||
typedef signed long ssize_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
typedef signed int int32_t;
|
||||
|
||||
typedef enum {
|
||||
false, true
|
||||
} bool;
|
||||
|
||||
/**
|
||||
* Attributes
|
||||
@@ -43,8 +36,6 @@ typedef enum {
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
#define NULL ((void*)0)
|
||||
|
||||
#define JERRY_BITSINBYTE 8
|
||||
|
||||
/**
|
||||
@@ -99,8 +90,10 @@ extern void __noreturn jerry_AssertFail( const char *assertion, const char *file
|
||||
/**
|
||||
* Mark for unreachable points and unimplemented cases
|
||||
*/
|
||||
#define JERRY_UNREACHABLE() do { JERRY_ASSERT( false); __builtin_trap(); } while (0)
|
||||
extern void jerry_RefUnusedVariables(int unused_variables_follow, ...);
|
||||
#define JERRY_UNREACHABLE() do { JERRY_ASSERT( false); jerry_Exit( ERR_GENERAL); } while (0)
|
||||
#define JERRY_UNIMPLEMENTED() JERRY_UNREACHABLE()
|
||||
#define JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(...) do { JERRY_UNIMPLEMENTED(); if ( false ) { jerry_RefUnusedVariables( 0, __VA_ARGS__); } } while (0)
|
||||
|
||||
/**
|
||||
* Exit
|
||||
|
||||
@@ -99,7 +99,7 @@ opfunc_loop_inf (OPCODE opdata, struct __int_data *int_data)
|
||||
}
|
||||
|
||||
void
|
||||
opfunc_call_1 (OPCODE opdata, struct __int_data *int_data)
|
||||
opfunc_call_1 (OPCODE opdata __unused, struct __int_data *int_data)
|
||||
{
|
||||
#ifdef __HOST
|
||||
__printf ("%d::op_call_1:idx:%d:%d\n",
|
||||
|
||||
@@ -258,7 +258,7 @@ ecma_GCRun( void)
|
||||
|
||||
if ( pObject->m_IsLexicalEnvironment )
|
||||
{
|
||||
ecma_Object_t *pOuterLexicalEnvironment = ecma_GetPointer( pObject->u_Attributes.m_LexicalEnvironment.m_pOuterReference);
|
||||
ecma_Object_t *pOuterLexicalEnvironment = ecma_GetPointer( pObject->u.m_LexicalEnvironment.m_pOuterReference);
|
||||
|
||||
if ( pOuterLexicalEnvironment != NULL )
|
||||
{
|
||||
@@ -266,7 +266,7 @@ ecma_GCRun( void)
|
||||
}
|
||||
} else
|
||||
{
|
||||
ecma_Object_t *pPrototypeObject = ecma_GetPointer( pObject->u_Attributes.m_Object.m_pPrototypeObject);
|
||||
ecma_Object_t *pPrototypeObject = ecma_GetPointer( pObject->u.m_Object.m_pPrototypeObject);
|
||||
|
||||
if ( pPrototypeObject != NULL )
|
||||
{
|
||||
|
||||
@@ -101,12 +101,12 @@ typedef enum {
|
||||
*/
|
||||
typedef struct {
|
||||
/** Value type (ecma_Type_t) */
|
||||
uint32_t m_ValueType : 2;
|
||||
unsigned int m_ValueType : 2;
|
||||
|
||||
/**
|
||||
* Simple value (ecma_SimpleValue_t) or compressed pointer to value (depending on m_ValueType)
|
||||
*/
|
||||
uint32_t m_Value : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_Value : ECMA_POINTER_FIELD_WIDTH;
|
||||
} __packed ecma_Value_t;
|
||||
|
||||
/**
|
||||
@@ -116,15 +116,21 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
/** Type (ecma_CompletionType_t) */
|
||||
uint32_t completion_type : 3;
|
||||
unsigned int type : 3;
|
||||
|
||||
/** Value */
|
||||
ecma_Value_t completion_value;
|
||||
ecma_Value_t value;
|
||||
|
||||
/** Target */
|
||||
uint32_t target : 8;
|
||||
unsigned int target : 8;
|
||||
} __packed ecma_CompletionValue_t;
|
||||
|
||||
/**
|
||||
* Target value indicating that target field
|
||||
* of ecma_CompletionValue_t defines no target.
|
||||
*/
|
||||
#define ECMA_TARGET_ID_RESERVED 255
|
||||
|
||||
/**
|
||||
* Internal properties' identifiers.
|
||||
*/
|
||||
@@ -152,10 +158,10 @@ typedef enum {
|
||||
*/
|
||||
typedef struct ecma_Property_t {
|
||||
/** Property's type (ecma_PropertyType_t) */
|
||||
uint32_t m_Type : 2;
|
||||
unsigned int m_Type : 2;
|
||||
|
||||
/** Compressed pointer to next property */
|
||||
uint32_t m_pNextProperty : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_pNextProperty : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Property's details (depending on m_Type) */
|
||||
union {
|
||||
@@ -163,16 +169,16 @@ typedef struct ecma_Property_t {
|
||||
/** Description of named data property */
|
||||
struct __packed ecma_NamedDataProperty_t {
|
||||
/** Compressed pointer to property's name (pointer to String) */
|
||||
uint32_t m_pName : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_pName : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Attribute 'Writable' */
|
||||
uint32_t m_Writable : 1;
|
||||
unsigned int m_Writable : 1;
|
||||
|
||||
/** Attribute 'Enumerable' */
|
||||
uint32_t m_Enumerable : 1;
|
||||
unsigned int m_Enumerable : 1;
|
||||
|
||||
/** Attribute 'Configurable' */
|
||||
uint32_t m_Configurable : 1;
|
||||
unsigned int m_Configurable : 1;
|
||||
|
||||
/** Value */
|
||||
ecma_Value_t m_Value;
|
||||
@@ -181,28 +187,28 @@ typedef struct ecma_Property_t {
|
||||
/** Description of named accessor property */
|
||||
struct __packed ecma_NamedAccessorProperty_t {
|
||||
/** Compressed pointer to property's name (pointer to String) */
|
||||
uint32_t m_pName : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_pName : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Attribute 'Enumerable' */
|
||||
uint32_t m_Enumerable : 1;
|
||||
unsigned int m_Enumerable : 1;
|
||||
|
||||
/** Attribute 'Configurable' */
|
||||
uint32_t m_Configurable : 1;
|
||||
unsigned int m_Configurable : 1;
|
||||
|
||||
/** Compressed pointer to property's getter */
|
||||
uint32_t m_pGet : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_pGet : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Compressed pointer to property's setter */
|
||||
uint32_t m_pSet : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_pSet : ECMA_POINTER_FIELD_WIDTH;
|
||||
} m_NamedAccessorProperty;
|
||||
|
||||
/** Description of internal property */
|
||||
struct __packed ecma_InternalProperty_t {
|
||||
/** Internal property's type */
|
||||
uint32_t m_InternalPropertyType : 4;
|
||||
unsigned int m_InternalPropertyType : 4;
|
||||
|
||||
/** Value (may be a compressed pointer) */
|
||||
uint32_t m_Value : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_Value : ECMA_POINTER_FIELD_WIDTH;
|
||||
} m_InternalProperty;
|
||||
} u;
|
||||
} ecma_Property_t;
|
||||
@@ -215,7 +221,7 @@ typedef struct {
|
||||
* Flag that indicates if the object is valid for normal usage.
|
||||
* If the flag is zero, then the object is not valid and is queued for GC.
|
||||
*/
|
||||
uint32_t m_IsObjectValid : 1;
|
||||
unsigned int m_IsObjectValid : 1;
|
||||
|
||||
/** Details (depending on m_IsObjectValid) */
|
||||
union {
|
||||
@@ -227,10 +233,10 @@ typedef struct {
|
||||
* which is limited by size of address space allocated for JerryScript
|
||||
* (and, consequently, by ECMA_POINTER_FIELD_WIDTH).
|
||||
*/
|
||||
uint32_t m_Refs : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_Refs : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Compressed pointer to next object in the list of objects, queued for GC (if !m_IsObjectValid) */
|
||||
uint32_t m_NextQueuedForGC : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_NextQueuedForGC : ECMA_POINTER_FIELD_WIDTH;
|
||||
} __packed u;
|
||||
} ecma_GCInfo_t;
|
||||
|
||||
@@ -248,11 +254,11 @@ typedef enum {
|
||||
*/
|
||||
typedef struct ecma_Object_t {
|
||||
/** Compressed pointer to property list */
|
||||
uint32_t m_pProperties : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_pProperties : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Flag indicating whether it is a general object (false)
|
||||
or a lexical environment (true) */
|
||||
uint32_t m_IsLexicalEnvironment : 1;
|
||||
unsigned int m_IsLexicalEnvironment : 1;
|
||||
|
||||
/**
|
||||
* Attributes of either general object or lexical environment
|
||||
@@ -264,10 +270,10 @@ typedef struct ecma_Object_t {
|
||||
*/
|
||||
struct {
|
||||
/** Attribute 'Extensible' */
|
||||
uint32_t m_Extensible : 1;
|
||||
unsigned int m_Extensible : 1;
|
||||
|
||||
/** Compressed pointer to prototype object (ecma_Object_t) */
|
||||
uint32_t m_pPrototypeObject : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_pPrototypeObject : ECMA_POINTER_FIELD_WIDTH;
|
||||
} __packed m_Object;
|
||||
|
||||
/**
|
||||
@@ -277,13 +283,13 @@ typedef struct ecma_Object_t {
|
||||
/**
|
||||
* Type of lexical environment (ecma_LexicalEnvironmentType_t).
|
||||
*/
|
||||
uint32_t m_Type : 1;
|
||||
unsigned int m_Type : 1;
|
||||
|
||||
/** Compressed pointer to outer lexical environment */
|
||||
uint32_t m_pOuterReference : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_pOuterReference : ECMA_POINTER_FIELD_WIDTH;
|
||||
} __packed m_LexicalEnvironment;
|
||||
|
||||
} __packed u_Attributes;
|
||||
} __packed u;
|
||||
|
||||
/** GC's information */
|
||||
ecma_GCInfo_t m_GCInfo;
|
||||
@@ -342,6 +348,30 @@ typedef struct {
|
||||
uint8_t m_Elements[ ECMA_ARRAY_CHUNK_SIZE_IN_BYTES - sizeof (uint16_t) ];
|
||||
} ecma_ArrayNonFirstChunk_t;
|
||||
|
||||
/**
|
||||
* \addtogroup reference ECMA-reference
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* ECMA-reference (see also: ECMA-262 v5, 8.7).
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/** base value */
|
||||
ecma_Value_t base;
|
||||
|
||||
/** referenced name value pointer */
|
||||
ecma_Char_t *referenced_name_p;
|
||||
|
||||
/** strict reference flag */
|
||||
bool is_strict;
|
||||
} ecma_Reference_t;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* JERRY_ECMA_GLOBALS_H */
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/* Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** \addtogroup ecma ---TODO---
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmahelpers Helpers for operations with ECMA data types
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "globals.h"
|
||||
|
||||
/**
|
||||
* Check if the value is undefined.
|
||||
*
|
||||
* @return true - if the value contains ecma-undefined simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool
|
||||
ecma_IsUndefinedValue( ecma_Value_t value) /**< ecma-value */
|
||||
{
|
||||
return ( value.m_ValueType == ECMA_TYPE_SIMPLE && value.m_Value == ECMA_SIMPLE_VALUE_UNDEFINED );
|
||||
} /* ecma_IsUndefinedValue */
|
||||
|
||||
/**
|
||||
* Check if the value is null.
|
||||
*
|
||||
* @return true - if the value contains ecma-null simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool
|
||||
ecma_IsNullValue( ecma_Value_t value) /**< ecma-value */
|
||||
{
|
||||
return ( value.m_ValueType == ECMA_TYPE_SIMPLE && value.m_Value == ECMA_SIMPLE_VALUE_NULL );
|
||||
} /* ecma_IsNullValue */
|
||||
|
||||
/**
|
||||
* Check if the value is boolean.
|
||||
*
|
||||
* @return true - if the value contains ecma-true or ecma-false simple values,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool
|
||||
ecma_IsBooleanValue( ecma_Value_t value) /**< ecma-value */
|
||||
{
|
||||
return ( ( value.m_ValueType == ECMA_TYPE_SIMPLE && value.m_Value == ECMA_SIMPLE_VALUE_FALSE )
|
||||
|| ( value.m_ValueType == ECMA_TYPE_SIMPLE && value.m_Value == ECMA_SIMPLE_VALUE_TRUE ) );
|
||||
} /* ecma_IsBooleanValue */
|
||||
|
||||
/**
|
||||
* Check if the value is true.
|
||||
*
|
||||
* Warning:
|
||||
* value must be boolean
|
||||
*
|
||||
* @return true - if the value contains ecma-true simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool
|
||||
ecma_IsValueTrue( ecma_Value_t value) /**< ecma-value */
|
||||
{
|
||||
JERRY_ASSERT( ecma_IsBooleanValue( value) );
|
||||
|
||||
return ( value.m_ValueType == ECMA_TYPE_SIMPLE && value.m_Value == ECMA_SIMPLE_VALUE_TRUE );
|
||||
} /* ecma_IsValueTrue */
|
||||
|
||||
/**
|
||||
* Simple value constructor
|
||||
*/
|
||||
ecma_Value_t
|
||||
ecma_MakeSimpleValue( ecma_SimpleValue_t value) /**< simple value */
|
||||
{
|
||||
return (ecma_Value_t) { .m_ValueType = ECMA_TYPE_SIMPLE, .m_Value = value };
|
||||
} /* ecma_MakeSimpleValue */
|
||||
|
||||
/**
|
||||
* Object value constructor
|
||||
*/
|
||||
ecma_Value_t
|
||||
ecma_MakeObjectValue( ecma_Object_t* object_p) /**< object to reference in value */
|
||||
{
|
||||
JERRY_ASSERT( object_p != NULL );
|
||||
|
||||
ecma_Value_t object_value;
|
||||
|
||||
object_value.m_ValueType = ECMA_TYPE_OBJECT;
|
||||
ecma_SetPointer( object_value.m_Value, object_p);
|
||||
|
||||
return object_value;
|
||||
} /* ecma_MakeObjectValue */
|
||||
|
||||
/**
|
||||
* Completion value constructor
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_MakeCompletionValue(ecma_CompletionType_t type, /**< type */
|
||||
ecma_Value_t value, /**< value */
|
||||
uint8_t target) /**< target */
|
||||
{
|
||||
return (ecma_CompletionValue_t) { .type = type, .value = value, .target = target };
|
||||
} /* ecma_MakeCompletionValue */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
@@ -20,10 +20,6 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of helpers for operations with ECMA data types
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
@@ -94,8 +90,8 @@ ecma_CreateObject( ecma_Object_t *pPrototypeObject, /**< pointer to prototybe of
|
||||
* (at least with the ctx_GlobalObject variable) */
|
||||
pObject->m_GCInfo.u.m_Refs = 1;
|
||||
|
||||
pObject->u_Attributes.m_Object.m_Extensible = isExtensible;
|
||||
ecma_SetPointer( pObject->u_Attributes.m_Object.m_pPrototypeObject, pPrototypeObject);
|
||||
pObject->u.m_Object.m_Extensible = isExtensible;
|
||||
ecma_SetPointer( pObject->u.m_Object.m_pPrototypeObject, pPrototypeObject);
|
||||
|
||||
return pObject;
|
||||
} /* ecma_CreateObject */
|
||||
@@ -119,14 +115,14 @@ ecma_CreateLexicalEnvironment(ecma_Object_t *pOuterLexicalEnvironment, /**< oute
|
||||
ecma_Object_t *pNewLexicalEnvironment = ecma_AllocObject();
|
||||
|
||||
pNewLexicalEnvironment->m_IsLexicalEnvironment = true;
|
||||
pNewLexicalEnvironment->u_Attributes.m_LexicalEnvironment.m_Type = type;
|
||||
pNewLexicalEnvironment->u.m_LexicalEnvironment.m_Type = type;
|
||||
|
||||
pNewLexicalEnvironment->m_pProperties = ECMA_NULL_POINTER;
|
||||
|
||||
pNewLexicalEnvironment->m_GCInfo.m_IsObjectValid = true;
|
||||
pNewLexicalEnvironment->m_GCInfo.u.m_Refs = 1;
|
||||
|
||||
ecma_SetPointer( pNewLexicalEnvironment->u_Attributes.m_LexicalEnvironment.m_pOuterReference, pOuterLexicalEnvironment);
|
||||
ecma_SetPointer( pNewLexicalEnvironment->u.m_LexicalEnvironment.m_pOuterReference, pOuterLexicalEnvironment);
|
||||
|
||||
return pNewLexicalEnvironment;
|
||||
} /* ecma_CreateLexicalEnvironment */
|
||||
@@ -157,7 +153,7 @@ ecma_CreateInternalProperty(ecma_Object_t *pObject, /**< the object */
|
||||
/**
|
||||
* Find internal property in the object's property set.
|
||||
*
|
||||
* @return pointer to the property's descriptor, if it is found,
|
||||
* @return pointer to the property, if it is found,
|
||||
* NULL - otherwise.
|
||||
*/
|
||||
ecma_Property_t*
|
||||
@@ -204,6 +200,47 @@ ecma_GetInternalProperty(ecma_Object_t *pObject, /**< object descriptor */
|
||||
return pProperty;
|
||||
} /* ecma_GetInternalProperty */
|
||||
|
||||
/**
|
||||
* Find named data property or named access property in specified object.
|
||||
*
|
||||
* @return pointer to the property, if it is found,
|
||||
* NULL - otherwise.
|
||||
*/
|
||||
ecma_Property_t*
|
||||
ecma_FindNamedProperty(ecma_Object_t *obj_p, /**< object to find property in */
|
||||
ecma_Char_t *string_p) /**< property's name */
|
||||
{
|
||||
JERRY_ASSERT( obj_p != NULL );
|
||||
JERRY_ASSERT( string_p != NULL );
|
||||
|
||||
for ( ecma_Property_t *property_p = ecma_GetPointer( obj_p->m_pProperties);
|
||||
property_p != NULL;
|
||||
property_p = ecma_GetPointer( property_p->m_pNextProperty) )
|
||||
{
|
||||
ecma_ArrayFirstChunk_t *property_name_p;
|
||||
|
||||
if ( property_p->m_Type == ECMA_PROPERTY_NAMEDDATA )
|
||||
{
|
||||
property_name_p = ecma_GetPointer( property_p->u.m_NamedDataProperty.m_pName);
|
||||
} else if ( property_p->m_Type == ECMA_PROPERTY_NAMEDACCESSOR )
|
||||
{
|
||||
property_name_p = ecma_GetPointer( property_p->u.m_NamedAccessorProperty.m_pName);
|
||||
} else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
JERRY_ASSERT( property_name_p != NULL );
|
||||
|
||||
if ( ecma_CompareCharBufferToEcmaString( string_p, property_name_p) )
|
||||
{
|
||||
return property_p;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
} /* ecma_FindNamedProperty */
|
||||
|
||||
/**
|
||||
* Allocate new ecma-string and fill it with characters from specified buffer
|
||||
*
|
||||
|
||||
@@ -41,6 +41,15 @@ extern void* ecma_DecompressPointer(uintptr_t compressedPointer);
|
||||
#define ecma_SetPointer( field, nonCompressedPointer) \
|
||||
(field) = ecma_CompressPointer( nonCompressedPointer) & ( ( 1u << ECMA_POINTER_FIELD_WIDTH ) - 1)
|
||||
|
||||
extern ecma_Value_t ecma_MakeSimpleValue( ecma_SimpleValue_t value);
|
||||
extern ecma_Value_t ecma_MakeObjectValue( ecma_Object_t* object_p);
|
||||
extern ecma_CompletionValue_t ecma_MakeCompletionValue( ecma_CompletionType_t type, ecma_Value_t value, uint8_t target);
|
||||
|
||||
extern bool ecma_IsUndefinedValue( ecma_Value_t value);
|
||||
extern bool ecma_IsNullValue( ecma_Value_t value);
|
||||
extern bool ecma_IsBooleanValue( ecma_Value_t value);
|
||||
extern bool ecma_IsValueTrue( ecma_Value_t value);
|
||||
|
||||
extern ecma_Object_t* ecma_CreateObject( ecma_Object_t *pPrototypeObject, bool isExtensible);
|
||||
extern ecma_Object_t* ecma_CreateLexicalEnvironment( ecma_Object_t *pOuterLexicalEnvironment, ecma_LexicalEnvironmentType_t type);
|
||||
|
||||
@@ -49,6 +58,8 @@ extern ecma_Property_t* ecma_FindInternalProperty(ecma_Object_t *pObject, ecma_I
|
||||
extern ecma_Property_t* ecma_GetInternalProperty(ecma_Object_t *pObject, ecma_InternalPropertyId_t propertyId);
|
||||
extern ecma_Property_t* ecma_SetInternalProperty(ecma_Object_t *pObject, ecma_InternalPropertyId_t propertyId);
|
||||
|
||||
extern ecma_Property_t *ecma_FindNamedProperty(ecma_Object_t *obj_p, ecma_Char_t *string_p);
|
||||
|
||||
extern ecma_ArrayFirstChunk_t* ecma_NewEcmaString( const ecma_Char_t *pString, ecma_Length_t length);
|
||||
extern ssize_t ecma_CopyEcmaStringCharsToBuffer( ecma_ArrayFirstChunk_t *pFirstChunk, uint8_t *pBuffer, size_t bufferSize);
|
||||
extern ecma_ArrayFirstChunk_t* ecma_DuplicateEcmaString( ecma_ArrayFirstChunk_t *pFirstChunk);
|
||||
@@ -61,4 +72,4 @@ extern void ecma_FreeArray( ecma_ArrayFirstChunk_t *pFirstChunk);
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -21,37 +21,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup syntacticreference Textual reference to variable/property
|
||||
* \addtogroup reference ECMA-reference
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Syntactic (textual/unresolved) reference to a variable/object's property.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* Flag indicating that this is reference to a property.
|
||||
*
|
||||
* Note:
|
||||
* m_PropertyName is valid only if m_IsPropertyReference is true.
|
||||
*/
|
||||
uint32_t m_IsPropertyReference : 1;
|
||||
|
||||
/**
|
||||
* Flag indicating that this reference is strict (see also: ECMA-262 v5, 8.7).
|
||||
*/
|
||||
uint32_t m_StrictReference : 1;
|
||||
|
||||
/**
|
||||
* Name of variable (Null-terminated string).
|
||||
*/
|
||||
ecma_Char_t* m_Name;
|
||||
|
||||
/**
|
||||
* Name of object's property (Null-terminated string).
|
||||
*/
|
||||
ecma_Char_t* m_PropertyName;
|
||||
} ecma_SyntacticReference_t;
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
/* Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of ECMA GetValue and PutValue
|
||||
*/
|
||||
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lex-env.h"
|
||||
#include "ecma-operations.h"
|
||||
|
||||
/** \addtogroup ecma ---TODO---
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmaoperations ECMA-defined operations
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resolve syntactic reference to ECMA-reference.
|
||||
*
|
||||
* Warning: string pointed by name_p
|
||||
* must not be freed or reused
|
||||
* until the reference is freed.
|
||||
*
|
||||
* @return ECMA-reference (if base value is an object, upon return
|
||||
* it's reference counter is increased by one).
|
||||
*/
|
||||
ecma_Reference_t
|
||||
ecma_OpGetIdentifierReference(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_Char_t *name_p, /**< identifier's name */
|
||||
bool is_strict) /**< strict reference flag */
|
||||
{
|
||||
JERRY_ASSERT( lex_env_p != NULL );
|
||||
|
||||
ecma_Object_t *lex_env_iter_p = lex_env_p;
|
||||
|
||||
while ( lex_env_iter_p != NULL )
|
||||
{
|
||||
ecma_CompletionValue_t completion_value;
|
||||
completion_value = ecma_OpHasBinding( lex_env_iter_p, name_p);
|
||||
|
||||
JERRY_ASSERT( completion_value.type == ECMA_COMPLETION_TYPE_NORMAL );
|
||||
|
||||
if ( ecma_IsValueTrue( completion_value.value) )
|
||||
{
|
||||
ecma_RefObject( lex_env_iter_p);
|
||||
|
||||
return (ecma_Reference_t) { .base = ecma_MakeObjectValue( lex_env_iter_p),
|
||||
.referenced_name_p = name_p,
|
||||
.is_strict = is_strict };
|
||||
}
|
||||
|
||||
lex_env_iter_p = ecma_GetPointer( lex_env_iter_p->u.m_LexicalEnvironment.m_pOuterReference);
|
||||
}
|
||||
|
||||
return (ecma_Reference_t) { .base = ecma_MakeObjectValue( NULL),
|
||||
.referenced_name_p = NULL,
|
||||
.is_strict = is_strict };
|
||||
} /* ecma_OpGetIdentifierReference */
|
||||
|
||||
/**
|
||||
* GetValue operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 8.7.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpGetValue( ecma_Reference_t *ref_p) /**< ECMA-reference */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( ref_p);
|
||||
} /* ecma_OpGetValue */
|
||||
|
||||
/**
|
||||
* SetValue operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 8.7.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpSetValue(ecma_Reference_t *ref_p, /**< ECMA-reference */
|
||||
ecma_Value_t value) /**< ECMA-value */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( ref_p, value);
|
||||
} /* ecma_OpSetValue */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,153 @@
|
||||
/* Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lex-env.h"
|
||||
#include "globals.h"
|
||||
|
||||
/** \addtogroup ecma ---TODO---
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup lexicalenvironment Lexical environment
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* HasBinding operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpHasBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_Char_t *name_p) /**< argument N */
|
||||
{
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->m_IsLexicalEnvironment );
|
||||
|
||||
ecma_SimpleValue_t has_binding = ECMA_SIMPLE_VALUE_UNDEFINED;
|
||||
|
||||
switch ( (ecma_LexicalEnvironmentType_t) lex_env_p->u.m_LexicalEnvironment.m_Type )
|
||||
{
|
||||
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
||||
{
|
||||
ecma_Property_t *property_p = ecma_FindNamedProperty( lex_env_p, name_p);
|
||||
|
||||
has_binding = ( property_p != NULL ) ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE;
|
||||
}
|
||||
case ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND:
|
||||
{
|
||||
JERRY_UNIMPLEMENTED();
|
||||
}
|
||||
}
|
||||
|
||||
return ecma_MakeCompletionValue(ECMA_COMPLETION_TYPE_NORMAL,
|
||||
ecma_MakeSimpleValue( has_binding),
|
||||
ECMA_TARGET_ID_RESERVED);
|
||||
} /* ecma_OpHasBinding */
|
||||
|
||||
/**
|
||||
* CreateMutableBinding operation.
|
||||
*
|
||||
* see also: ecma-262 v5, 10.2.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpCreateMutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_Char_t *name_p, /**< argument N */
|
||||
bool is_deletable) /**< argument D */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p, name_p, is_deletable);
|
||||
} /* ecma_OpCreateMutableBinding */
|
||||
|
||||
/**
|
||||
* SetMutableBinding operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpSetMutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_Char_t *name_p, /**< argument N */
|
||||
ecma_Value_t value, /**< argument V */
|
||||
bool is_strict) /**< argument S */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p, name_p, value, is_strict);
|
||||
} /* ecma_OpSetMutableBinding */
|
||||
|
||||
/**
|
||||
* GetBindingValue operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpGetBindingValue(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_Char_t *name_p, /**< argument N */
|
||||
bool is_strict) /**< argument S */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p, name_p, is_strict);
|
||||
} /* ecma_OpGetBindingValue */
|
||||
|
||||
/**
|
||||
* DeleteBinding operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpDeleteBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_Char_t *name_p) /**< argument N */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p, name_p);
|
||||
} /* ecma_OpDeleteBinding */
|
||||
|
||||
/**
|
||||
* ImplicitThisValue operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpImplicitThisValue( ecma_Object_t *lex_env_p) /**< lexical environment */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p);
|
||||
} /* ecma_OpImplicitThisValue */
|
||||
|
||||
/**
|
||||
* CreateImmutableBinding operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpCreateImmutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_Char_t *name_p) /**< argument N */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p, name_p);
|
||||
} /* ecma_OpCreateImmutableBinding */
|
||||
|
||||
/**
|
||||
* InitializeImmutableBinding operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpInitializeImmutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_Char_t *name_p, /**< argument N */
|
||||
ecma_Value_t value) /**< argument V */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p, name_p, value);
|
||||
} /* ecma_OpInitializeImmutableBinding */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,48 @@
|
||||
/* Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ECMA_LEX_ENV_H
|
||||
#define ECMA_LEX_ENV_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "globals.h"
|
||||
|
||||
/** \addtogroup ecma ---TODO---
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup lexicalenvironment Lexical environment
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* ECMA-262 v5, Table 17. Abstract methods of Environment Records */
|
||||
extern ecma_CompletionValue_t ecma_OpHasBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p);
|
||||
extern ecma_CompletionValue_t ecma_OpCreateMutableBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p, bool is_deletable);
|
||||
extern ecma_CompletionValue_t ecma_OpSetMutableBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p, ecma_Value_t value, bool is_strict);
|
||||
extern ecma_CompletionValue_t ecma_OpGetBindingValue( ecma_Object_t *lex_env_p, ecma_Char_t *name_p, bool is_strict);
|
||||
extern ecma_CompletionValue_t ecma_OpDeleteBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p);
|
||||
extern ecma_CompletionValue_t ecma_OpImplicitThisValue( ecma_Object_t *lex_env_p);
|
||||
|
||||
/* ECMA-262 v5, Table 18. Additional methods of Declarative Environment Records */
|
||||
extern ecma_CompletionValue_t ecma_OpCreateImmutableBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p);
|
||||
extern ecma_CompletionValue_t ecma_OpInitializeImmutableBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p, ecma_Value_t value);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !ECMA_LEX_ENV_H */
|
||||
@@ -26,8 +26,10 @@
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-reference.h"
|
||||
|
||||
extern ecma_CompletionValue_t ecma_GetValue( ecma_SyntacticReference_t *ref_p);
|
||||
extern ecma_CompletionValue_t ecma_SetValue( ecma_SyntacticReference_t *ref_p, ecma_Value_t value);
|
||||
extern ecma_Reference_t ecma_OpGetIdentifierReference( ecma_Object_t *lex_env_p, ecma_Char_t *name_p, bool is_strict);
|
||||
|
||||
extern ecma_CompletionValue_t ecma_OpGetValue( ecma_Reference_t *ref_p);
|
||||
extern ecma_CompletionValue_t ecma_OpSetValue( ecma_Reference_t *ref_p, ecma_Value_t value);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -83,7 +83,7 @@ static string_and_token keyword_tokens[] =
|
||||
static string_and_token seen_names[MAX_NAMES];
|
||||
static uint8_t seen_names_num;
|
||||
|
||||
static inline bool
|
||||
static bool
|
||||
is_empty (token tok)
|
||||
{
|
||||
return tok.type == TOK_EMPTY;
|
||||
@@ -233,7 +233,7 @@ lexer_get_string_by_id (string_id id)
|
||||
return seen_names[id].str;
|
||||
}
|
||||
|
||||
static inline void
|
||||
static void
|
||||
new_token (void)
|
||||
{
|
||||
JERRY_ASSERT (buffer);
|
||||
@@ -247,7 +247,7 @@ consume_char (void)
|
||||
buffer++;
|
||||
}
|
||||
|
||||
static inline const char *
|
||||
static const char *
|
||||
current_token (void)
|
||||
{
|
||||
JERRY_ASSERT (buffer);
|
||||
|
||||
@@ -19,6 +19,36 @@
|
||||
|
||||
#include "jerry-libc.h"
|
||||
|
||||
/**
|
||||
* memcpy alias to __memcpy (for compiler usage)
|
||||
*/
|
||||
extern void *memcpy(void *s1, const void*s2, size_t n);
|
||||
|
||||
/**
|
||||
* memset alias to __memset (for compiler usage)
|
||||
*/
|
||||
extern void *memset(void *s, int c, size_t n);
|
||||
|
||||
/**
|
||||
* memcpy alias to __memcpy (for compiler usage)
|
||||
*/
|
||||
void* memcpy(void *s1, /**< destination */
|
||||
const void* s2, /**< source */
|
||||
size_t n) /**< bytes number */
|
||||
{
|
||||
return __memcpy(s1, s2, n);
|
||||
} /* memcpy */
|
||||
|
||||
/**
|
||||
* memset alias to __memset (for compiler usage)
|
||||
*/
|
||||
void* memset(void *s, /**< area to set values in */
|
||||
int c, /**< value to set */
|
||||
size_t n) /**< area size */
|
||||
{
|
||||
return __memset(s, c, n);
|
||||
} /* memset */
|
||||
|
||||
/**
|
||||
* memset
|
||||
*
|
||||
@@ -26,8 +56,8 @@
|
||||
*/
|
||||
void*
|
||||
__memset(void *s, /**< area to set values in */
|
||||
int c, /**< value to set */
|
||||
size_t n) /**< area size */
|
||||
int c, /**< value to set */
|
||||
size_t n) /**< area size */
|
||||
{
|
||||
uint8_t *pArea = s;
|
||||
for ( size_t index = 0; index < n; index++ )
|
||||
|
||||
@@ -55,6 +55,6 @@ extern int __fprintf(FILE *, const char *, ...);
|
||||
#define DBL_DIG ( 10)
|
||||
#define DBL_MIN_EXP (-324)
|
||||
#define DBL_MAX_EXP ( 308)
|
||||
#define HUGE_VAL (1e37)
|
||||
#define HUGE_VAL (1e37f)
|
||||
|
||||
#endif /* JERRY_LIBC_H */
|
||||
|
||||
@@ -48,7 +48,8 @@ pp_token (token tok)
|
||||
break;
|
||||
|
||||
case TOK_FLOAT:
|
||||
__printf ("FLOAT (%f)\n", tok.data.fp_num);
|
||||
FIXME(int -> float);
|
||||
__printf ("FLOAT (%d)\n", (int)tok.data.fp_num);
|
||||
break;
|
||||
|
||||
case TOK_NULL:
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
* Handle failed assertion
|
||||
*/
|
||||
void __noreturn
|
||||
jerry_AssertFail(const char *assertion, /**< assertion condition string */
|
||||
const char *file, /**< file name */
|
||||
const uint32_t line) /** line */
|
||||
jerry_AssertFail(const char *assertion __unused, /**< assertion condition string */
|
||||
const char *file __unused, /**< file name */
|
||||
const uint32_t line __unused) /** line */
|
||||
{
|
||||
__exit( -ERR_GENERAL);
|
||||
} /* jerry_AssertFail */
|
||||
|
||||
@@ -36,8 +36,13 @@ __printf(const char *format, /**< format string */
|
||||
|
||||
va_start( args, format);
|
||||
|
||||
int ret = vprintf( format, args);
|
||||
|
||||
/**
|
||||
* TODO: Call internal vprintf implementation when it appears.
|
||||
*/
|
||||
int ret = 0;
|
||||
|
||||
JERRY_UNIMPLEMENTED();
|
||||
|
||||
va_end( args);
|
||||
|
||||
return ret;
|
||||
@@ -52,7 +57,7 @@ __putchar (int c)
|
||||
|
||||
/** exit - cause normal process termination */
|
||||
void __noreturn
|
||||
__exit (int status)
|
||||
__exit (int status __unused)
|
||||
{
|
||||
/**
|
||||
* TODO: Blink LEDs? status -> binary -> LEDs?
|
||||
|
||||
@@ -13,6 +13,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "serializer.h"
|
||||
#include "globals.h"
|
||||
|
||||
void
|
||||
serializer_init (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
serializer_dump_data (const void *data __unused, size_t size __unused)
|
||||
{
|
||||
}
|
||||
|
||||
TODO (Dump memory)
|
||||
+28
-19
@@ -14,9 +14,14 @@
|
||||
*/
|
||||
|
||||
#ifdef __TARGET_MCU
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
#include "stm32f4xx.h"
|
||||
#include "stm32f4xx_gpio.h"
|
||||
#include "stm32f4xx_rcc.h"
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#define LED_GREEN 12
|
||||
#define LED_ORANGE 13
|
||||
@@ -45,11 +50,11 @@ void
|
||||
fake_exit (void)
|
||||
{
|
||||
#ifdef __TARGET_MCU
|
||||
int pin = LED_RED;
|
||||
uint32_t mode = GPIO_Mode_OUT << (pin * 2);
|
||||
uint32_t speed = GPIO_Speed_100MHz << (pin * 2);
|
||||
uint32_t type = GPIO_OType_PP << pin;
|
||||
uint32_t pullup = GPIO_PuPd_NOPULL << (pin * 2);
|
||||
uint32_t pin = LED_RED;
|
||||
uint32_t mode = (uint32_t)GPIO_Mode_OUT << (pin * 2);
|
||||
uint32_t speed = (uint32_t)GPIO_Speed_100MHz << (pin * 2);
|
||||
uint32_t type = (uint32_t)GPIO_OType_PP << pin;
|
||||
uint32_t pullup = (uint32_t)GPIO_PuPd_NOPULL << (pin * 2);
|
||||
//
|
||||
// Initialise the peripheral clock.
|
||||
//
|
||||
@@ -57,10 +62,12 @@ fake_exit (void)
|
||||
//
|
||||
// Initilaise the GPIO port.
|
||||
//
|
||||
GPIOD->MODER |= mode;
|
||||
GPIOD->OSPEEDR |= speed;
|
||||
GPIOD->OTYPER |= type;
|
||||
GPIOD->PUPDR |= pullup;
|
||||
volatile GPIO_TypeDef* gpio = GPIOD;
|
||||
|
||||
gpio->MODER |= mode;
|
||||
gpio->OSPEEDR |= speed;
|
||||
gpio->OTYPER |= type;
|
||||
gpio->PUPDR |= pullup;
|
||||
//
|
||||
// Toggle the selected LED indefinitely.
|
||||
//
|
||||
@@ -73,17 +80,17 @@ fake_exit (void)
|
||||
|
||||
while (1)
|
||||
{
|
||||
GPIOD->BSRRL = (1 << pin); for (index = 0; index < dot; index++); GPIOD->BSRRH = (1 << pin); for (index = 0; index < dash; index++);
|
||||
GPIOD->BSRRL = (1 << pin); for (index = 0; index < dot; index++); GPIOD->BSRRH = (1 << pin); for (index = 0; index < dash; index++);
|
||||
GPIOD->BSRRL = (1 << pin); for (index = 0; index < dot; index++); GPIOD->BSRRH = (1 << pin); for (index = 0; index < dash; index++);
|
||||
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
|
||||
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
|
||||
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
|
||||
|
||||
GPIOD->BSRRL = (1 << pin); for (index = 0; index < dash; index++); GPIOD->BSRRH = (1 << pin); for (index = 0; index < dash; index++);
|
||||
GPIOD->BSRRL = (1 << pin); for (index = 0; index < dash; index++); GPIOD->BSRRH = (1 << pin); for (index = 0; index < dash; index++);
|
||||
GPIOD->BSRRL = (1 << pin); for (index = 0; index < dash; index++); GPIOD->BSRRH = (1 << pin); for (index = 0; index < dash; index++);
|
||||
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
|
||||
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
|
||||
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
|
||||
|
||||
GPIOD->BSRRL = (1 << pin); for (index = 0; index < dot; index++); GPIOD->BSRRH = (1 << pin); for (index = 0; index < dash; index++);
|
||||
GPIOD->BSRRL = (1 << pin); for (index = 0; index < dot; index++); GPIOD->BSRRH = (1 << pin); for (index = 0; index < dash; index++);
|
||||
GPIOD->BSRRL = (1 << pin); for (index = 0; index < dot; index++); GPIOD->BSRRH = (1 << pin);
|
||||
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
|
||||
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
|
||||
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin);
|
||||
|
||||
for (index = 0; index < dash * 7; index++);
|
||||
}
|
||||
@@ -113,8 +120,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
statement st;
|
||||
uint8_t dump = 0;
|
||||
const char *file_name = NULL;
|
||||
#ifdef __HOST
|
||||
const char *file_name = NULL;
|
||||
FILE *file = NULL;
|
||||
#endif
|
||||
|
||||
@@ -129,8 +136,10 @@ main (int argc, char **argv)
|
||||
dump |= DUMP_AST;
|
||||
else if (!__strcmp ("-b", argv[i]))
|
||||
dump |= DUMP_BYTECODE;
|
||||
#ifdef __HOST
|
||||
else if (file_name == NULL)
|
||||
file_name = argv[i];
|
||||
#endif
|
||||
else
|
||||
jerry_Exit (ERR_SEVERAL_FILES);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user