Skip to content

Commit a7c6946

Browse files
committed
Add: minor fixings and changes.
1 parent 6c9795b commit a7c6946

File tree

9 files changed

+61
-19
lines changed

9 files changed

+61
-19
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ ADDED:
1919
-- Deferred code block and error handling;
2020
-- Typed function decorators;
2121
-- Class decorator and Apsect-Oriented Programming;
22+
-- Invariables and invar classes;
23+
-- Boolean type;
2224
-- Enum/flag/symbol type;
2325
-- Variant or disjoint union type: type1|type2;
2426
-- Hash map type (colliding keys as red-black tree);
27+
-- Support for customized comparisons and hashing;
2528
-- Explicit enumeration with keywords: array/list/map/tuple{};
2629
-- Verbatim string syntax;
2730
-- Customized for-in iteration;
@@ -32,6 +35,7 @@ ADDED:
3235
-- Support for template-like C data type;
3336
-- Standard help system;
3437
CHANGED:
38+
-- "float" type to double precision (with "double" type removed);
3539
-- Internal data storage structures;
3640
-- Better parsing with a combination of top-down and bottom-up parsing;
3741
-- Better handling of control branching;

demo/deployment.dao

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
# make -f Makefile.daomake macosx MODE=debug OPTIONS="--option-BUNDLE-SCRIPT demo/deployment --option-BUNDLE-RESOURCES demo/resource.txt"
3+
24
load mixins
35

46
text = std::resource( "@demo/resource.txt" )

kernel/daoBytecode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2237,7 +2237,8 @@ static void DaoByteCoder_DecodeClass( DaoByteCoder *self, DaoByteBlock *block )
22372237
klass->intOperators = DaoClass_FindMethod( klass, "(int)", NULL );
22382238
klass->eqOperators = DaoClass_FindMethod( klass, "==", NULL );
22392239
klass->ltOperators = DaoClass_FindMethod( klass, "<", NULL );
2240-
if( klass->attribs != (C & ~DAO_CLS_ASYNCHRONOUS) ){ /* check inferred attributes: */
2240+
/* Check inferred attributes: */
2241+
if( klass->attribs != (C & ~(DAO_CLS_INVAR|DAO_CLS_ASYNCHRONOUS)) ){
22412242
DaoByteCoder_Error( self, block, "Class attributes not matching!" );
22422243
}
22432244
klass->attribs = C;

kernel/daoOptimizer.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6217,21 +6217,23 @@ int DaoInferencer_DoInference( DaoInferencer *self )
62176217
break;
62186218
case DVM_SETVH_BB : case DVM_SETVH_II : case DVM_SETVH_FF : case DVM_SETVH_CC :
62196219
tp = typeVH[opc] + opb;
6220-
if( *tp == NULL || (*tp)->tid == DAO_UDT ){
6221-
GC_Assign( tp, types[opa] );
6220+
if( at->tid <= DAO_ENUM ) at = DaoType_GetBaseType( at );
6221+
if( *tp == NULL || (*tp)->tid == DAO_UDT || (*tp)->tid == DAO_THT ){
6222+
GC_Assign( tp, at );
62226223
}
62236224
TT1 = DAO_BOOLEAN + (code - DVM_SETVH_BB);
6224-
AssertTypeMatching( types[opa], *tp, defs );
6225+
AssertTypeMatching( at, *tp, defs );
62256226
AssertTypeIdMatching( at, TT1 );
62266227
AssertTypeIdMatching( tp[0], TT1 );
62276228
break;
62286229
case DVM_SETVS_BB : case DVM_SETVS_II : case DVM_SETVS_FF : case DVM_SETVS_CC :
62296230
var = body->upValues->items.pVar[opb];
6230-
if( var->dtype == NULL || var->dtype->tid == DAO_UDT ){
6231+
if( at->tid <= DAO_ENUM ) at = DaoType_GetBaseType( at );
6232+
if( var->dtype == NULL || var->dtype->tid == DAO_UDT || var->dtype->tid == DAO_THT ){
62316233
DaoVariable_SetType( var, at );
62326234
}
62336235
TT1 = DAO_BOOLEAN + (code - DVM_SETVS_BB);
6234-
AssertTypeMatching( types[opa], var->dtype, defs );
6236+
AssertTypeMatching( at, var->dtype, defs );
62356237
AssertTypeIdMatching( at, TT1 );
62366238
AssertTypeIdMatching( var->dtype, TT1 );
62376239
break;
@@ -6242,21 +6244,22 @@ int DaoInferencer_DoInference( DaoInferencer *self )
62426244
if( !(routine->attribs & DAO_ROUT_INITOR) ) goto ModifyConstant;
62436245
at = DaoType_GetInvarType( at );
62446246
}
6245-
if( var->dtype == NULL || var->dtype->tid == DAO_UDT ){
6247+
if( var->dtype == NULL || var->dtype->tid == DAO_UDT || var->dtype->tid == DAO_THT ){
62466248
DaoVariable_SetType( var, at );
62476249
}
62486250
TT1 = DAO_BOOLEAN + (code - DVM_SETVO_BB);
6249-
AssertTypeMatching( types[opa], var->dtype, defs );
6251+
AssertTypeMatching( at, var->dtype, defs );
62506252
AssertTypeIdMatching( at, TT1 );
62516253
AssertTypeIdMatching( var->dtype, TT1 );
62526254
break;
62536255
case DVM_SETVK_BB : case DVM_SETVK_II : case DVM_SETVK_FF : case DVM_SETVK_CC :
62546256
var = hostClass->variables->items.pVar[opb];
6255-
if( var->dtype == NULL || var->dtype->tid == DAO_UDT ){
6257+
if( at->tid <= DAO_ENUM ) at = DaoType_GetBaseType( at );
6258+
if( var->dtype == NULL || var->dtype->tid == DAO_UDT || var->dtype->tid == DAO_THT ){
62566259
DaoVariable_SetType( var, at );
62576260
}
62586261
TT1 = DAO_BOOLEAN + (code - DVM_SETVK_BB);
6259-
AssertTypeMatching( types[opa], var->dtype, defs );
6262+
AssertTypeMatching( at, var->dtype, defs );
62606263
AssertTypeIdMatching( at, TT1 );
62616264
AssertTypeIdMatching( var->dtype, TT1 );
62626265
break;
@@ -6265,11 +6268,12 @@ int DaoInferencer_DoInference( DaoInferencer *self )
62656268
if( !(opc & 0x4) && var->dtype && var->dtype->invar ) goto ModifyConstant;
62666269
if( (opc >> 1) == 0x3 ) at = DaoType_GetInvarType( at );
62676270
if( (opc & 0x4) == 0 && at->konst == 1 ) at = DaoType_GetBaseType( at );
6268-
if( var->dtype == NULL || var->dtype->tid == DAO_UDT ){
6271+
if( at->tid <= DAO_ENUM ) at = DaoType_GetBaseType( at );
6272+
if( var->dtype == NULL || var->dtype->tid == DAO_UDT || var->dtype->tid == DAO_THT ){
62696273
DaoVariable_SetType( var, at );
62706274
}
62716275
TT1 = DAO_BOOLEAN + (code - DVM_SETVG_BB);
6272-
AssertTypeMatching( types[opa], var->dtype, defs );
6276+
AssertTypeMatching( at, var->dtype, defs );
62736277
AssertTypeIdMatching( at, TT1 );
62746278
AssertTypeIdMatching( var->dtype, TT1 );
62756279
break;

license.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Dao Programming Language
22
http://www.daovm.net
33

4-
Copyright (c) 2006-2013, Limin Fu
4+
Copyright (c) 2006-2014, Limin Fu
55
All rights reserved.
66

77
Redistribution and use in source and binary forms, with or without modification,

modules/help/help_en/help_dao_grammar.dao

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ TypeKeyword ::= type | any | bool | int | float | complex | string
114114

115115
-- Structures:
116116
@[code(syntax)]
117-
StructKeyword ::= interface | class | routine | operator
117+
StructKeyword ::= interface | class | routine
118118
@[code(syntax)]
119119

120120
-- Storage/scoping:
@@ -657,6 +657,7 @@ Type ::= SpecialType
657657
| [ 'dao' '::' ] TupleType
658658
| [ 'dao' '::' ] RoutineType
659659
| { Identifier '::' } UserType
660+
| ( 'var' | 'invar' ) '<' Type '>'
660661
@[code(syntax)]
661662

662663

@@ -840,7 +841,7 @@ Expression
840841
Expression ::= PrimaryExpression
841842
| LeftUnaryOperator PrimaryExpression
842843
| PrimaryExpression BinaryOperator PrimaryExpression
843-
| (Type) Expression
844+
| '(' Type ')' PrimaryExpression
844845
| AnonymousRoutine
845846
@[code(syntax)]
846847

@@ -1118,7 +1119,7 @@ CodeBlockSig ::= Identifier '(' [ ParamList ] ')' '[' [ ParamList1 ] ']' [ '=>'
11181119
DecoratorSig ::= TypeHolder '(' Identifier '(' Identifier ')' [ ',' ParamList ] ')'
11191120

11201121
RoutineDecl1 ::= 'routine' { Identifier '::' } ( RoutineSig | CodeBlockSig | DecoratorSig )
1121-
RoutineDecl2 ::= 'operator' { Identifier '::' } OverloadableOperator ParamReturn
1122+
RoutineDecl2 ::= 'routine' { Identifier '::' } OverloadableOperator ParamReturn
11221123

11231124
RoutineDecl ::= RoutineDecl1 | RoutineDecl2
11241125

modules/help/help_zh/help_dao_grammar.dao

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ TypeKeyword ::= type | any | int | float | complex | string
8989

9090
-- Structures:
9191
@[code(syntax)]
92-
StructKeyword ::= interface | class | routine | operator
92+
StructKeyword ::= interface | class | routine
9393
@[code(syntax)]
9494

9595
-- Storage/scoping:
@@ -632,6 +632,7 @@ Type ::= SpecialType
632632
| [ 'dao' '::' ] TupleType
633633
| [ 'dao' '::' ] RoutineType
634634
| { Identifier '::' } UserType
635+
| ( 'var' | 'invar' ) '<' Type '>'
635636
@[code(syntax)]
636637

637638

@@ -815,7 +816,7 @@ Expression
815816
Expression ::= PrimaryExpression
816817
| LeftUnaryOperator PrimaryExpression
817818
| PrimaryExpression BinaryOperator PrimaryExpression
818-
| (Type) Expression
819+
| '(' Type ')' PrimaryExpression
819820
| AnonymousRoutine
820821
@[code(syntax)]
821822

@@ -1093,7 +1094,7 @@ CodeBlockSig ::= Identifier '(' [ ParamList ] ')' '[' [ ParamList1 ] ']' [ '=>'
10931094
DecoratorSig ::= TypeHolder '(' Identifier '(' Identifier ')' [ ',' ParamList ] ')'
10941095

10951096
RoutineDecl1 ::= 'routine' { Identifier '::' } ( RoutineSig | CodeBlockSig | DecoratorSig )
1096-
RoutineDecl2 ::= 'operator' { Identifier '::' } OverloadableOperator ParamReturn
1097+
RoutineDecl2 ::= 'routine' { Identifier '::' } OverloadableOperator ParamReturn
10971098

10981099
RoutineDecl ::= RoutineDecl1 | RoutineDecl2
10991100

share/release.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
make -f Makefile.daomake macosx
2+
3+
mkdir Dao-$VERSION
4+
cd Dao-$VERSION
5+
fossil open --nested ../Dao.fossil
6+
fossil close
7+
8+
mkdir -p doc
9+
cp -r ../doc/html doc/
10+
11+
cd ../modules
12+
fossil open --nested ../../modules/DaoModules.fossil
13+
fossil close
14+
15+
cd ../tools
16+
fossil open --nested ../../tools/DaoTools.fossil
17+
fossil close

tests/test_type.dao

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11

2+
3+
@[test(code_01)]
4+
var a: dao::int
5+
var b: dao::string
6+
var c: dao::list<int>
7+
var d: dao::tuple<int,string>
8+
@[test(code_01)]
9+
@[test(code_01)]
10+
@[test(code_01)]
11+
12+
13+
214
# Test auto-type casting:
315
@[test(code_01)]
416
var a : none|int = 123

0 commit comments

Comments
 (0)